<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>class RubyXL::Worksheet - rubyXL 3.4.35</title>


  <meta name="keywords" content="ruby,class,RubyXL::Worksheet">


    <meta name="description" content="class RubyXL::Worksheet: www. datypic.">





<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">



<body id="top" role="document" class="class">
<div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
  <span aria-hidden="true">&#9776;</span>
</div>


<nav id="navigation" role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  

  
<div id="parent-class-section" class="nav-section">
  <h3>Ancestors</h3>
  <ul><li><a href="OOXMLTopLevelObject.html">RubyXL::OOXMLTopLevelObject</a><ul><li><a href="OOXMLObject.html">RubyXL::OOXMLObject</a><ul><li>Object</li></ul></li></ul></li></ul>
</div>


  
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">


    <li><a class="include" href="RelationshipSupport.html">RubyXL::RelationshipSupport</a></li>



    <li><a class="include" href="LegacyWorksheet.html">RubyXL::LegacyWorksheet</a></li>


  </ul>
</div>


  

  
  <div class="nav-section">
    <h3>Class Methods</h3>
    <ul class="link-list" role="directory">

      <li class="calls-super" ><a href="#method-c-parse">parse</a></li>

    </ul>
  </div>



  <div class="nav-section">
    <h3>Instance Methods</h3>
    <ul class="link-list" role="directory">

      <li ><a href="#method-i-before_write_xml">before_write_xml</a></li>

      <li ><a href="#method-i-cell_at">cell_at</a></li>

      <li ><a href="#method-i-get_col_xf">get_col_xf</a></li>

      <li ><a href="#method-i-get_row_xf">get_row_xf</a></li>

      <li ><a href="#method-i-related_objects">related_objects</a></li>

      <li ><a href="#method-i-xlsx_path">xlsx_path</a></li>

    </ul>
  </div>



  <footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a></p>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.15.1.</p>
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>
</footer>

</nav>

<main role="main" aria-labelledby="class-RubyXL::Worksheet">
  
  
    <ol role="navigation" aria-label="Breadcrumb navigation" class="breadcrumb">
      
      <li>
        
        <a href="../RubyXL.html">RubyXL</a><span>::</span>
        
      </li>
      
      <li>
        
        <span>Worksheet</span>
        
      </li>
      
    </ol>
  

  <h1 id="class-RubyXL::Worksheet" class="anchor-link class">
    class RubyXL::Worksheet
  </h1>

  <section class="description">
    
<p><a href="http://www.datypic.com/sc/ooxml/e-ssml_worksheet.html">www.datypic.com/sc/ooxml/e-ssml_worksheet.html</a></p>

  </section>


  <section id="5Buntitled-5D" class="documentation-section anchor-link">





    <section class="constants-list">
      <header>
        <h3>Constants</h3>
      </header>
      <dl>

        <dt id="CONTENT_TYPE">CONTENT_TYPE</dt>

        <dd>

          
        </dd>


        <dt id="REL_TYPE">REL_TYPE</dt>

        <dd>

          
        </dd>


      </dl>
    </section>



    <section class="attribute-method-details method-section">
      <header>
        <h3>Attributes</h3>
      </header>


      <div id="attribute-i-rels" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-rels" title="Link to this attribute">
            <span class="method-name">rels</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

      <div id="attribute-i-sheet_id" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-sheet_id" title="Link to this attribute">
            <span class="method-name">sheet_id</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

      <div id="attribute-i-sheet_name" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-sheet_name" title="Link to this attribute">
            <span class="method-name">sheet_name</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

      <div id="attribute-i-state" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-state" title="Link to this attribute">
            <span class="method-name">state</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

      <div id="attribute-i-workbook" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-workbook" title="Link to this attribute">
            <span class="method-name">workbook</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

    </section>



     <section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Class Methods</h3>
       </header>


      <div id="method-c-parse" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-c-parse" title="Link to this method">
                <span class="method-name">parse</span>
                <span class="method-args">(param)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 736</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse</span>(<span class="ruby-identifier">param</span>)
  <span class="ruby-identifier">sheet_obj</span> = <span class="ruby-keyword">super</span>
  <span class="ruby-identifier">sheet_obj</span>.<span class="ruby-identifier">sheet_data</span>.<span class="ruby-identifier">rows</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">r</span>.<span class="ruby-identifier">worksheet</span> = <span class="ruby-identifier">sheet_obj</span>
    <span class="ruby-identifier">r</span>.<span class="ruby-identifier">cells</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">worksheet</span> = <span class="ruby-identifier">sheet_obj</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">nil?</span> }
  }
  <span class="ruby-identifier">sheet_obj</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


            <div class="method-calls-super">
              Calls superclass method
              
            </div>

        </div>





      </div>


    </section>

     <section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Instance Methods</h3>
       </header>


      <div id="method-i-before_write_xml" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-before_write_xml" title="Link to this method">
                <span class="method-name">before_write_xml</span>
                <span class="method-args">()</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="before_write_xml-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 687</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">before_write_xml</span> <span class="ruby-comment"># This method may need to be moved higher in the hierarchy</span>
  <span class="ruby-identifier">first_nonempty_row</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">last_nonempty_row</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">first_nonempty_column</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">last_nonempty_column</span> = <span class="ruby-value">0</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">sheet_data</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">sheet_data</span>.<span class="ruby-identifier">rows</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span>, <span class="ruby-identifier">row_index</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">row</span>.<span class="ruby-identifier">cells</span>.<span class="ruby-identifier">empty?</span>

      <span class="ruby-identifier">first_nonempty_cell</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-identifier">last_nonempty_cell</span> = <span class="ruby-value">0</span>

      <span class="ruby-identifier">row</span>.<span class="ruby-identifier">cells</span>.<span class="ruby-identifier">each_with_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">cell</span>, <span class="ruby-identifier">col_index</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">cell</span>.<span class="ruby-identifier">nil?</span>
        <span class="ruby-identifier">cell</span>.<span class="ruby-identifier">r</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Reference</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">row_index</span>, <span class="ruby-identifier">col_index</span>)

        <span class="ruby-identifier">first_nonempty_cell</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">col_index</span>
        <span class="ruby-identifier">last_nonempty_cell</span> = <span class="ruby-identifier">col_index</span>
      }

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">first_nonempty_cell</span> <span class="ruby-keyword">then</span> <span class="ruby-comment"># If there&#39;s nothing in this row, then +first_nonempty_cell+ will be +nil+.</span>
        <span class="ruby-identifier">last_nonempty_row</span> = <span class="ruby-identifier">row_index</span>
        <span class="ruby-identifier">first_nonempty_row</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">row_index</span>

        <span class="ruby-identifier">first_nonempty_column</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">first_nonempty_cell</span>
        <span class="ruby-identifier">last_nonempty_column</span> = <span class="ruby-identifier">last_nonempty_cell</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">last_nonempty_cell</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_nonempty_column</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">row</span>.<span class="ruby-identifier">r</span> = <span class="ruby-identifier">row_index</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
      <span class="ruby-identifier">row</span>.<span class="ruby-identifier">spans</span> = <span class="ruby-node">&quot;#{first_nonempty_cell + 1}:#{last_nonempty_cell + 1}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">first_nonempty_cell</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">row</span>.<span class="ruby-identifier">custom_format</span> = (<span class="ruby-identifier">row</span>.<span class="ruby-identifier">style_index</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>)
    }

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">first_nonempty_row</span> <span class="ruby-keyword">then</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dimension</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">WorksheetDimensions</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dimension</span>.<span class="ruby-identifier">ref</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Reference</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">first_nonempty_row</span>, <span class="ruby-identifier">last_nonempty_row</span>,
                                                 <span class="ruby-identifier">first_nonempty_column</span>, <span class="ruby-identifier">last_nonempty_column</span>)
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-cell_at" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-cell_at" title="Link to this method">
                <span class="method-name">cell_at</span>
                <span class="method-args">(ref)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="cell_at-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 754</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cell_at</span>(<span class="ruby-identifier">ref</span>)
  <span class="ruby-identifier">reference</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Reference</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ref</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Invalid reference: #{ref}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">reference</span>.<span class="ruby-identifier">valid?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">reference</span>.<span class="ruby-identifier">single_cell?</span>
  <span class="ruby-identifier">sheet_data</span>&amp;.<span class="ruby-identifier">rows</span>&amp;.<span class="ruby-identifier">[]</span>(<span class="ruby-identifier">reference</span>.<span class="ruby-identifier">first_row</span>)&amp;.<span class="ruby-identifier">cells</span>&amp;.<span class="ruby-identifier">[]</span>(<span class="ruby-identifier">reference</span>.<span class="ruby-identifier">first_col</span>)
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-get_col_xf" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-get_col_xf" title="Link to this method">
                <span class="method-name">get_col_xf</span>
                <span class="method-args">(column_index)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="get_col_xf-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 746</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_col_xf</span>(<span class="ruby-identifier">column_index</span>)
  <span class="ruby-identifier">workbook</span>.<span class="ruby-identifier">stylesheet</span>.<span class="ruby-identifier">cell_xfs</span>[<span class="ruby-identifier">get_col_style</span>(<span class="ruby-identifier">column_index</span>)]
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-get_row_xf" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-get_row_xf" title="Link to this method">
                <span class="method-name">get_row_xf</span>
                <span class="method-args">(row)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="get_row_xf-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 750</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_row_xf</span>(<span class="ruby-identifier">row</span>)
  <span class="ruby-identifier">workbook</span>.<span class="ruby-identifier">stylesheet</span>.<span class="ruby-identifier">cell_xfs</span>[<span class="ruby-identifier">get_row_style</span>(<span class="ruby-identifier">row</span>)]
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-related_objects" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-related_objects" title="Link to this method">
                <span class="method-name">related_objects</span>
                <span class="method-args">()</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="related_objects-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 621</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">related_objects</span>
  <span class="ruby-identifier">comments</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">printer_settings</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-xlsx_path" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-xlsx_path" title="Link to this method">
                <span class="method-name">xlsx_path</span>
                <span class="method-args">()</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="xlsx_path-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/worksheet.rb, line 732</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">xlsx_path</span>
  <span class="ruby-constant">ROOT</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;xl&#39;</span>, <span class="ruby-string">&#39;worksheets&#39;</span>, <span class="ruby-node">&quot;sheet#{file_index}.xml&quot;</span>)
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


    </section>

  </section>

</main>
</body>

